package bosque.unc.gui;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import javax.swing.JCheckBox;
import javax.swing.UIManager;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Locale;

import javax.swing.JTextField;
import javax.swing.border.TitledBorder;

import bosque.unc.ayuda.SensoresAyuda;
import bosque.unc.enumerations.Sensor;

import javax.swing.JButton;

import java.awt.Toolkit;
import java.awt.Color;

public class SensoresGUI extends JFrame 
{
	
    private static Scoba scoba;
    private HiloActualizacionSensoresGUI updater;
    private boolean flagMostrar = false; // flag para mostrar los valores en pantalla
	private JPanel contentPane;
	private JTextField textFieldADCSensCupula;
	private JTextField textFieldADCSensEspecEjeX;
	private JTextField textFieldADCSensEspecEjeY;
	private JTextField textFieldADCSensEspecFi;
	private JTextField textFieldADCSensTempExt;
	private JTextField textFieldADCSensTempEsp;
	private JTextField textFieldADCSensPlataArriAba;
	private JTextField textFieldADCSensPlataADAF;
	private JTextField textFieldSensFinesDeCarrera;
	private JTextField textFieldSensCheckPic;
	private JCheckBox chckbxSensEspecEjeX;
	private JCheckBox chckbxSensTempEsp;
	private JCheckBox chckbxSensEspecEjeY;
	private JCheckBox chckbxSensPlataAdenAfu;
	private JCheckBox chckbxSensCheckPic;
	private JCheckBox chckbxSensEspecFi;
	private JCheckBox chckbxSensCupula;
	private JCheckBox chckbxSensPlataARAB;
	private JCheckBox chckbxSensFinesDeCarrera;
	private JCheckBox chckbxSensTempExt;
	private JTextField textFieldSensPlataADAF;
	private JTextField textFieldSensPlataArriAba;
	private JTextField textFieldSensTempEsp;
	private JTextField textFieldSensTempExt;
	private JTextField textFieldSensEspecFi;
	private JTextField textFieldSensEspecEjeY;
	private JTextField textFieldSensEspecEjeX;
	private JTextField textFieldSensCupula;
	private JTextField textFieldFac5vPic;
	private JTextField textFieldFacTempAlim1;
	private JTextField textFieldFacTempAlim2;
	private JTextField textFieldFacCorrTempExt;
	private JTextField textFieldFacCorrTempEsp;
	private JTextField textFieldFacPlaAR0;
	private JTextField textFieldFacPlaAR1;
	private JTextField textFieldFacPlaAD0;
	private JTextField textFieldFacPlaAD1;
	private JTextField textFieldFacPlaRad0;
	private JTextField textFieldFacEspGanY;
	private JTextField textFieldFacEspGanX;
	private JTextField textFieldFacCorrCup;
	private JTextField textFieldFacCup1;
	private JTextField textFieldFacCup0;
	private JTextField textFieldFacCupOffset;
	private JTextField textFieldFacPlaRad1;
	private JTextField textFieldFacCorrPlaAlt;
	private JTextField textFieldFacCorrPlaRad;
	private JTextField textFieldFacCupGan;
	private JTextField textFieldDelayRampa;
	private JTextField textFieldMaxRampa;
	private JTextField textFieldMinRampa;
	private JTextField textFieldFacEspOffsetX;
	private JTextField textFieldFacEspOffsetY;
	private JTextField textFieldFacEspOffsetFi;
	private JTextField textFieldFacCorrEspX;
	private JTextField textFieldFacCorrEspY;
	private JTextField textFieldFacCorrEspFi;
	private JTextField textFieldFacEspGanFi;
	private JButton btnSensCargarArchivo;
	private JButton btnSensGuardarValores;
	private JButton btnSensCargarValores;
	private JButton btnSensActualizarLecturas;
	private JButton btnAyuda;

	
	private SensoresAyuda sensoresAyuda;
	private JTextField textFieldSegCupGrad;
	
	/**
	 * Launch the application.
	 */
	public static void main(String[] args)
	{
		EventQueue.invokeLater(new Runnable() 
		{
			public void run() 
			{
				
				try
				{
					System.out.println("Look and Fell: " + UIManager.getSystemLookAndFeelClassName());
					UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
				}
				catch (Exception ex)
				{
					System.out.println("Failed loading L&F: ");
					System.out.println(ex);
				}
				try {
					SensoresGUI frame = new SensoresGUI(scoba);
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public SensoresGUI(Scoba sba) 
	{
		setIconImage(Toolkit.getDefaultToolkit().getImage("D:\\WorkTesis\\Scoba\\src\\bosque\\unc\\gui\\resources\\AjusteSensores.png"));
		this.scoba = sba;
		addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosing(WindowEvent arg0) {
				flagMostrar = false;
			}
		});
		inicialize();
	}
	
	public void actualizarGui()
	{
		
			updater = new HiloActualizacionSensoresGUI(SensoresGUI.getScoba());
			updater.start();
		
	}
	
	public void inicialize()	
	{
		Locale.setDefault(Locale.US);
		setTitle("Activar - Desactivar lecutras de sensores ");
		setResizable(false);		
		setBounds(100, 100, 924, 501);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JPanel panelFactores = new JPanel();
		panelFactores.setLayout(null);
		panelFactores.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Factores de las funciones de transferencia", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panelFactores.setBounds(320, 11, 533, 272);
		contentPane.add(panelFactores);
		
		JLabel lblFarc5v = new JLabel("fac5vDelPic:");
		lblFarc5v.setHorizontalAlignment(SwingConstants.RIGHT);
		lblFarc5v.setBounds(10, 25, 89, 14);
		panelFactores.add(lblFarc5v);
		
		textFieldFac5vPic = new JTextField();
		textFieldFac5vPic.setColumns(10);
		textFieldFac5vPic.setBounds(109, 22, 60, 20);
		panelFactores.add(textFieldFac5vPic);
		

		
		JLabel lblFacTemp1 = new JLabel("facTempExtAlim");
		lblFacTemp1.setHorizontalAlignment(SwingConstants.RIGHT);
		lblFacTemp1.setBounds(10, 55, 89, 14);
		panelFactores.add(lblFacTemp1);
		
		textFieldFacTempAlim1 = new JTextField();
		textFieldFacTempAlim1.setColumns(10);
		textFieldFacTempAlim1.setBounds(109, 52, 60, 20);
		panelFactores.add(textFieldFacTempAlim1);
		
		JLabel lblFacTemp2 = new JLabel("facTempEspAlim");
		lblFacTemp2.setHorizontalAlignment(SwingConstants.RIGHT);
		lblFacTemp2.setBounds(10, 87, 89, 14);
		panelFactores.add(lblFacTemp2);
		
		textFieldFacTempAlim2 = new JTextField();
		textFieldFacTempAlim2.setColumns(10);
		textFieldFacTempAlim2.setBounds(109, 84, 60, 20);
		panelFactores.add(textFieldFacTempAlim2);
		
		JLabel lblTacPlaAR0 = new JLabel("facPlaAR0");
		lblTacPlaAR0.setHorizontalAlignment(SwingConstants.RIGHT);
		lblTacPlaAR0.setBounds(10, 118, 89, 14);
		panelFactores.add(lblTacPlaAR0);
		
		textFieldFacPlaAR0 = new JTextField();
		textFieldFacPlaAR0.setColumns(10);
		textFieldFacPlaAR0.setBounds(109, 115, 60, 20);
		panelFactores.add(textFieldFacPlaAR0);
		
		JLabel lblTacPlaAR1 = new JLabel("facPlaAR1");
		lblTacPlaAR1.setHorizontalAlignment(SwingConstants.RIGHT);
		lblTacPlaAR1.setBounds(10, 149, 89, 14);
		panelFactores.add(lblTacPlaAR1);
		
		textFieldFacPlaAR1 = new JTextField();
		textFieldFacPlaAR1.setColumns(10);
		textFieldFacPlaAR1.setBounds(109, 146, 60, 20);
		panelFactores.add(textFieldFacPlaAR1);
		
		JLabel lblFacPlaAD0 = new JLabel("facPlaAD0");
		lblFacPlaAD0.setHorizontalAlignment(SwingConstants.RIGHT);
		lblFacPlaAD0.setBounds(10, 180, 89, 14);
		panelFactores.add(lblFacPlaAD0);
		
		textFieldFacPlaAD0 = new JTextField();
		textFieldFacPlaAD0.setColumns(10);
		textFieldFacPlaAD0.setBounds(109, 177, 60, 20);
		panelFactores.add(textFieldFacPlaAD0);
		
		JLabel lblFacPlaAD1 = new JLabel("facPlaAD1");
		lblFacPlaAD1.setHorizontalAlignment(SwingConstants.RIGHT);
		lblFacPlaAD1.setBounds(10, 211, 89, 14);
		panelFactores.add(lblFacPlaAD1);
		
		textFieldFacPlaAD1 = new JTextField();
		textFieldFacPlaAD1.setColumns(10);
		textFieldFacPlaAD1.setBounds(109, 208, 60, 20);
		panelFactores.add(textFieldFacPlaAD1);
		
		JLabel lblFacPlaRa0 = new JLabel("facPlaRad0");
		lblFacPlaRa0.setHorizontalAlignment(SwingConstants.RIGHT);
		lblFacPlaRa0.setBounds(10, 242, 89, 14);
		panelFactores.add(lblFacPlaRa0);
		
		textFieldFacPlaRad0 = new JTextField();
		textFieldFacPlaRad0.setColumns(10);
		textFieldFacPlaRad0.setBounds(109, 239, 60, 20);
		panelFactores.add(textFieldFacPlaRad0);
		
		JLabel lblFacCup0 = new JLabel("facCup0");
		lblFacCup0.setHorizontalAlignment(SwingConstants.RIGHT);
		lblFacCup0.setBounds(179, 118, 89, 14);
		panelFactores.add(lblFacCup0);
		
		JLabel lblFacCup1 = new JLabel("facCup1");
		lblFacCup1.setHorizontalAlignment(SwingConstants.RIGHT);
		lblFacCup1.setBounds(179, 149, 89, 14);
		panelFactores.add(lblFacCup1);
		
		JLabel lblFacEspGanX = new JLabel("facEspGanX");
		lblFacEspGanX.setHorizontalAlignment(SwingConstants.RIGHT);
		lblFacEspGanX.setBounds(179, 180, 89, 14);
		panelFactores.add(lblFacEspGanX);
		
		JLabel lblFacEspGanY = new JLabel("facEspGanY");
		lblFacEspGanY.setHorizontalAlignment(SwingConstants.RIGHT);
		lblFacEspGanY.setBounds(179, 211, 89, 14);
		panelFactores.add(lblFacEspGanY);
		
		textFieldFacEspGanY = new JTextField();
		textFieldFacEspGanY.setColumns(10);
		textFieldFacEspGanY.setBounds(277, 208, 60, 20);
		panelFactores.add(textFieldFacEspGanY);
		
		textFieldFacEspGanX = new JTextField();
		textFieldFacEspGanX.setColumns(10);
		textFieldFacEspGanX.setBounds(277, 177, 60, 20);
		panelFactores.add(textFieldFacEspGanX);
		
		textFieldFacCup1 = new JTextField();
		textFieldFacCup1.setColumns(10);
		textFieldFacCup1.setBounds(277, 146, 60, 20);
		panelFactores.add(textFieldFacCup1);
		
		textFieldFacCup0 = new JTextField();
		textFieldFacCup0.setColumns(10);
		textFieldFacCup0.setBounds(277, 115, 60, 20);
		panelFactores.add(textFieldFacCup0);
		
		textFieldFacCupOffset = new JTextField();
		textFieldFacCupOffset.setColumns(10);
		textFieldFacCupOffset.setBounds(277, 84, 60, 20);
		panelFactores.add(textFieldFacCupOffset);
		
		JLabel lblFacCupOffset = new JLabel("facCupOffset");
		lblFacCupOffset.setHorizontalAlignment(SwingConstants.RIGHT);
		lblFacCupOffset.setBounds(189, 87, 79, 14);
		panelFactores.add(lblFacCupOffset);
		
		JLabel lblFacPlaRa1 = new JLabel("facPlaRad1");
		lblFacPlaRa1.setHorizontalAlignment(SwingConstants.RIGHT);
		lblFacPlaRa1.setBounds(178, 25, 89, 14);
		panelFactores.add(lblFacPlaRa1);
		
		textFieldFacPlaRad1 = new JTextField();
		textFieldFacPlaRad1.setColumns(10);
		textFieldFacPlaRad1.setBounds(277, 22, 60, 20);
		panelFactores.add(textFieldFacPlaRad1);
		
		textFieldFacCupGan = new JTextField();
		textFieldFacCupGan.setColumns(10);
		textFieldFacCupGan.setBounds(277, 52, 60, 20);
		panelFactores.add(textFieldFacCupGan);
		
		JLabel lblFacCupGan = new JLabel("facCupGan");
		lblFacCupGan.setHorizontalAlignment(SwingConstants.RIGHT);
		lblFacCupGan.setBounds(179, 55, 89, 14);
		panelFactores.add(lblFacCupGan);
		
		textFieldDelayRampa = new JTextField();
		textFieldDelayRampa.setColumns(10);
		textFieldDelayRampa.setBounds(457, 177, 60, 20);
		panelFactores.add(textFieldDelayRampa);
		
		JLabel lbllblFacCorrEspX = new JLabel("delayRampa");
		lbllblFacCorrEspX.setHorizontalAlignment(SwingConstants.RIGHT);
		lbllblFacCorrEspX.setBounds(358, 180, 89, 14);
		panelFactores.add(lbllblFacCorrEspX);
		
		JLabel lblMaxRampa = new JLabel("MaxRampa");
		lblMaxRampa.setHorizontalAlignment(SwingConstants.RIGHT);
		lblMaxRampa.setBounds(358, 149, 89, 14);
		panelFactores.add(lblMaxRampa);
		
		textFieldMaxRampa = new JTextField();
		textFieldMaxRampa.setColumns(10);
		textFieldMaxRampa.setBounds(457, 146, 60, 20);
		panelFactores.add(textFieldMaxRampa);
		
		textFieldMinRampa = new JTextField();
		textFieldMinRampa.setColumns(10);
		textFieldMinRampa.setBounds(457, 115, 60, 20);
		panelFactores.add(textFieldMinRampa);
		
		JLabel lblMinRampa = new JLabel("MinRampa");
		lblMinRampa.setHorizontalAlignment(SwingConstants.RIGHT);
		lblMinRampa.setBounds(358, 118, 89, 14);
		panelFactores.add(lblMinRampa);
		
		JLabel lblFacEspOffsetFi = new JLabel("facEspOffsetFi");
		lblFacEspOffsetFi.setHorizontalAlignment(SwingConstants.RIGHT);
		lblFacEspOffsetFi.setBounds(358, 87, 89, 14);
		panelFactores.add(lblFacEspOffsetFi);
		
		JLabel lblFacEspOffsetY = new JLabel("facEspOffsetY");
		lblFacEspOffsetY.setHorizontalAlignment(SwingConstants.RIGHT);
		lblFacEspOffsetY.setBounds(358, 55, 89, 14);
		panelFactores.add(lblFacEspOffsetY);
		
		JLabel lblFacEspOffsetX = new JLabel("facEspOffsetX");
		lblFacEspOffsetX.setHorizontalAlignment(SwingConstants.RIGHT);
		lblFacEspOffsetX.setBounds(358, 25, 89, 14);
		panelFactores.add(lblFacEspOffsetX);
		
		textFieldFacEspOffsetX = new JTextField();
		textFieldFacEspOffsetX.setColumns(10);
		textFieldFacEspOffsetX.setBounds(457, 22, 60, 20);
		panelFactores.add(textFieldFacEspOffsetX);
		
		textFieldFacEspOffsetY = new JTextField();
		textFieldFacEspOffsetY.setColumns(10);
		textFieldFacEspOffsetY.setBounds(457, 52, 60, 20);
		panelFactores.add(textFieldFacEspOffsetY);
		
		textFieldFacEspOffsetFi = new JTextField();
		textFieldFacEspOffsetFi.setColumns(10);
		textFieldFacEspOffsetFi.setBounds(457, 84, 60, 20);
		panelFactores.add(textFieldFacEspOffsetFi);
		
		JLabel lblFacEspGanFi = new JLabel("facEspGanFi");
		lblFacEspGanFi.setHorizontalAlignment(SwingConstants.RIGHT);
		lblFacEspGanFi.setBounds(179, 242, 89, 14);
		panelFactores.add(lblFacEspGanFi);
		
		textFieldFacEspGanFi = new JTextField();
		textFieldFacEspGanFi.setColumns(10);
		textFieldFacEspGanFi.setBounds(277, 239, 60, 20);
		panelFactores.add(textFieldFacEspGanFi);
		
		JPanel panelSensores = new JPanel();
		panelSensores.setBorder(new TitledBorder(null, "Sensores", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panelSensores.setBounds(10, 11, 300, 415);
		contentPane.add(panelSensores);
		panelSensores.setLayout(null);
		
		textFieldSensCheckPic = new JTextField();
		textFieldSensCheckPic.setBounds(148, 323, 52, 20);
		panelSensores.add(textFieldSensCheckPic);
		textFieldSensCheckPic.setHorizontalAlignment(SwingConstants.RIGHT);
		textFieldSensCheckPic.setEditable(false);
		textFieldSensCheckPic.setColumns(10);
		
		chckbxSensCheckPic = new JCheckBox("Verif. PIC");
		chckbxSensCheckPic.setBounds(12, 322, 126, 23);
		panelSensores.add(chckbxSensCheckPic);
		
		chckbxSensFinesDeCarrera = new JCheckBox("Fines de Carrera");
		chckbxSensFinesDeCarrera.setBounds(12, 291, 126, 23);
		panelSensores.add(chckbxSensFinesDeCarrera);
		
		chckbxSensPlataAdenAfu = new JCheckBox("Plataforma AD/AF");
		chckbxSensPlataAdenAfu.setBounds(12, 260, 126, 23);
		panelSensores.add(chckbxSensPlataAdenAfu);
		
		textFieldSensFinesDeCarrera = new JTextField();
		textFieldSensFinesDeCarrera.setBounds(148, 292, 52, 20);
		panelSensores.add(textFieldSensFinesDeCarrera);
		textFieldSensFinesDeCarrera.setHorizontalAlignment(SwingConstants.RIGHT);
		textFieldSensFinesDeCarrera.setEditable(false);
		textFieldSensFinesDeCarrera.setColumns(10);
		
		textFieldADCSensPlataADAF = new JTextField();
		textFieldADCSensPlataADAF.setBounds(148, 261, 52, 20);
		panelSensores.add(textFieldADCSensPlataADAF);
		textFieldADCSensPlataADAF.setHorizontalAlignment(SwingConstants.RIGHT);
		textFieldADCSensPlataADAF.setEditable(false);
		textFieldADCSensPlataADAF.setColumns(10);
		
		textFieldADCSensPlataArriAba = new JTextField();
		textFieldADCSensPlataArriAba.setBounds(148, 230, 52, 20);
		panelSensores.add(textFieldADCSensPlataArriAba);
		textFieldADCSensPlataArriAba.setHorizontalAlignment(SwingConstants.RIGHT);
		textFieldADCSensPlataArriAba.setEditable(false);
		textFieldADCSensPlataArriAba.setColumns(10);
		
		textFieldADCSensTempEsp = new JTextField();
		textFieldADCSensTempEsp.setBounds(148, 199, 52, 20);
		panelSensores.add(textFieldADCSensTempEsp);
		textFieldADCSensTempEsp.setHorizontalAlignment(SwingConstants.RIGHT);
		textFieldADCSensTempEsp.setEditable(false);
		textFieldADCSensTempEsp.setColumns(10);
		
		textFieldADCSensTempExt = new JTextField();
		textFieldADCSensTempExt.setBounds(148, 168, 52, 20);
		panelSensores.add(textFieldADCSensTempExt);
		textFieldADCSensTempExt.setHorizontalAlignment(SwingConstants.RIGHT);
		textFieldADCSensTempExt.setEditable(false);
		textFieldADCSensTempExt.setColumns(10);
		
		textFieldADCSensEspecFi = new JTextField();
		textFieldADCSensEspecFi.setBounds(148, 137, 52, 20);
		panelSensores.add(textFieldADCSensEspecFi);
		textFieldADCSensEspecFi.setHorizontalAlignment(SwingConstants.RIGHT);
		textFieldADCSensEspecFi.setEditable(false);
		textFieldADCSensEspecFi.setColumns(10);
		
		textFieldADCSensEspecEjeY = new JTextField();
		textFieldADCSensEspecEjeY.setBounds(148, 106, 52, 20);
		panelSensores.add(textFieldADCSensEspecEjeY);
		textFieldADCSensEspecEjeY.setHorizontalAlignment(SwingConstants.RIGHT);
		textFieldADCSensEspecEjeY.setEditable(false);
		textFieldADCSensEspecEjeY.setColumns(10);
		
		textFieldADCSensEspecEjeX = new JTextField();
		textFieldADCSensEspecEjeX.setBounds(148, 75, 52, 20);
		panelSensores.add(textFieldADCSensEspecEjeX);
		textFieldADCSensEspecEjeX.setHorizontalAlignment(SwingConstants.RIGHT);
		textFieldADCSensEspecEjeX.setEditable(false);
		textFieldADCSensEspecEjeX.setColumns(10);
		
		textFieldADCSensCupula = new JTextField();
		textFieldADCSensCupula.setBounds(148, 44, 52, 20);
		panelSensores.add(textFieldADCSensCupula);
		textFieldADCSensCupula.setHorizontalAlignment(SwingConstants.RIGHT);
		textFieldADCSensCupula.setEditable(false);
		textFieldADCSensCupula.setColumns(10);
		
		textFieldSensCupula = new JTextField();
		textFieldSensCupula.setBounds(217, 44, 69, 21);
		panelSensores.add(textFieldSensCupula);
		textFieldSensCupula.setEditable(false);
		textFieldSensCupula.setColumns(10);
		soloNumeros(textFieldSensCupula);
		
		textFieldSensEspecEjeX = new JTextField();
		textFieldSensEspecEjeX.setBounds(217, 75, 69, 21);
		panelSensores.add(textFieldSensEspecEjeX);
		textFieldSensEspecEjeX.setEditable(false);
		textFieldSensEspecEjeX.setColumns(10);
		soloNumeros(textFieldSensEspecEjeX);
		
		textFieldSensPlataADAF = new JTextField();
		textFieldSensPlataADAF.setBounds(217, 261, 69, 20);
		panelSensores.add(textFieldSensPlataADAF);
		textFieldSensPlataADAF.setEditable(false);
		textFieldSensPlataADAF.setColumns(10);
		

			
			soloNumeros(textFieldSensPlataADAF);
			
			textFieldSensPlataArriAba = new JTextField();
			textFieldSensPlataArriAba.setBounds(217, 230, 69, 20);
			panelSensores.add(textFieldSensPlataArriAba);
			textFieldSensPlataArriAba.setEditable(false);
			textFieldSensPlataArriAba.setColumns(10);
			soloNumeros(textFieldSensPlataArriAba);
			
			textFieldSensTempEsp = new JTextField();
			textFieldSensTempEsp.setBounds(217, 199, 69, 20);
			panelSensores.add(textFieldSensTempEsp);
			textFieldSensTempEsp.setEditable(false);
			textFieldSensTempEsp.setColumns(10);
			soloNumeros(textFieldSensTempEsp);
			
			textFieldSensTempExt = new JTextField();
			textFieldSensTempExt.setBounds(217, 168, 69, 20);
			panelSensores.add(textFieldSensTempExt);
			textFieldSensTempExt.setEditable(false);
			textFieldSensTempExt.setColumns(10);
			soloNumeros(textFieldSensTempExt);
			
			textFieldSensEspecFi = new JTextField();
			textFieldSensEspecFi.setBounds(217, 137, 69, 20);
			panelSensores.add(textFieldSensEspecFi);
			textFieldSensEspecFi.setEditable(false);
			textFieldSensEspecFi.setColumns(10);
			soloNumeros(textFieldSensEspecFi);
			
			textFieldSensEspecEjeY = new JTextField();
			textFieldSensEspecEjeY.setBounds(217, 106, 69, 20);
			panelSensores.add(textFieldSensEspecEjeY);
			textFieldSensEspecEjeY.setEditable(false);
			textFieldSensEspecEjeY.setColumns(10);
			soloNumeros(textFieldSensEspecEjeY);
			
			JLabel lblLectura = new JLabel("LECTURA");
			lblLectura.setBounds(237, 19, 52, 14);
			panelSensores.add(lblLectura);
			
			JLabel lblAdc = new JLabel("ADC");
			lblAdc.setBounds(161, 19, 26, 14);
			panelSensores.add(lblAdc);
			
			chckbxSensCupula = new JCheckBox("Cupula");
			chckbxSensCupula.setBounds(12, 43, 97, 23);
			panelSensores.add(chckbxSensCupula);
			
			chckbxSensEspecEjeX = new JCheckBox("Espectrografo Eje X");
			chckbxSensEspecEjeX.setBounds(12, 71, 126, 23);
			panelSensores.add(chckbxSensEspecEjeX);
			
			chckbxSensPlataARAB = new JCheckBox("Plataforma AR/AB");
			chckbxSensPlataARAB.setBounds(12, 229, 126, 23);
			panelSensores.add(chckbxSensPlataARAB);
			
			chckbxSensTempEsp = new JCheckBox("Temp. Espejo");
			chckbxSensTempEsp.setBounds(12, 198, 126, 23);
			panelSensores.add(chckbxSensTempEsp);
			
			chckbxSensTempExt = new JCheckBox("Temp. Exterior");
			chckbxSensTempExt.setBounds(12, 167, 126, 23);
			panelSensores.add(chckbxSensTempExt);
			
			chckbxSensEspecFi = new JCheckBox("Espectrografo Fi");
			chckbxSensEspecFi.setBounds(12, 133, 126, 23);
			panelSensores.add(chckbxSensEspecFi);
			
			chckbxSensEspecEjeY = new JCheckBox("Espectrografo Eje Y");
			chckbxSensEspecEjeY.setBounds(12, 102, 126, 23);
			panelSensores.add(chckbxSensEspecEjeY);
			chckbxSensEspecEjeY.addActionListener(new ActionListener() 
			{
				public void actionPerformed(ActionEvent e) 
				{
					if(chckbxSensEspecEjeY.isSelected())
					{
						textFieldADCSensEspecEjeY.setEnabled(true);
						textFieldSensEspecEjeY.setEnabled(true);
						scoba.getLecturas().activarSensor(Sensor.ESPEC_Y, true);
					}
					else
					{
						textFieldADCSensEspecEjeY.setEnabled(false);
						textFieldSensEspecEjeY.setEnabled(false);
						scoba.getLecturas().activarSensor(Sensor.ESPEC_Y, false);
					}
					
				}
			});
			chckbxSensEspecFi.addActionListener(new ActionListener() 
			{
				public void actionPerformed(ActionEvent e)
				{
					if(chckbxSensEspecFi.isSelected())
					{
						textFieldADCSensEspecFi.setEnabled(true);
						textFieldSensEspecFi.setEnabled(true);
						scoba.getLecturas().activarSensor(Sensor.ESPEC_RED, true);
					}
					else
					{
						textFieldADCSensEspecFi.setEnabled(false);
						textFieldSensEspecFi.setEnabled(false);
						scoba.getLecturas().activarSensor(Sensor.ESPEC_RED, false);
					}
					
					
				}
			});
			chckbxSensTempExt.addActionListener(new ActionListener()
			{
				public void actionPerformed(ActionEvent e)
				{			
					if(chckbxSensTempExt.isSelected())
					{
						textFieldADCSensTempExt.setEnabled(true);
						textFieldSensTempExt.setEnabled(true);
						scoba.getLecturas().activarSensor(Sensor.TEMP_EXTERIOR, true);
					}
					else
					{
						textFieldADCSensTempExt.setEnabled(false);
						textFieldSensTempExt.setEnabled(false);
						scoba.getLecturas().activarSensor(Sensor.TEMP_EXTERIOR, false);
					}
					
					
				}
			});
			chckbxSensTempEsp.addActionListener(new ActionListener() 
			{
				public void actionPerformed(ActionEvent e) 
				{				
					if(chckbxSensTempEsp.isSelected())
					{
						textFieldADCSensTempEsp.setEnabled(true);
						textFieldSensTempEsp.setEnabled(true);
						scoba.getLecturas().activarSensor(Sensor.TEMP_ESPEJO, true);
					}
					else
					{
						textFieldADCSensTempEsp.setEnabled(false);
						textFieldSensTempEsp.setEnabled(false);
						scoba.getLecturas().activarSensor(Sensor.TEMP_ESPEJO, false);
					}
					
				}
			});
			chckbxSensPlataARAB.addActionListener(new ActionListener() 
			{
				public void actionPerformed(ActionEvent e) 
				{				
					if(chckbxSensPlataARAB.isSelected())
					{
						textFieldADCSensPlataArriAba.setEnabled(true);
						textFieldSensPlataArriAba.setEnabled(true);
						scoba.getLecturas().activarSensor(Sensor.PLATAF_AR_AB, true);
					}
					else
					{
						textFieldADCSensPlataArriAba.setEnabled(false);
						textFieldSensPlataArriAba.setEnabled(false);
						scoba.getLecturas().activarSensor(Sensor.PLATAF_AR_AB, false);
					}
					
				}
			});
			chckbxSensEspecEjeX.addActionListener(new ActionListener() 
			{
				public void actionPerformed(ActionEvent e) 
				{
					
					if(chckbxSensEspecEjeX.isSelected())
					{
						textFieldADCSensEspecEjeX.setEnabled(true);
						textFieldSensEspecEjeX.setEnabled(true);
						scoba.getLecturas().activarSensor(Sensor.ESPEC_X, true);
					}
					else
					{
						textFieldADCSensEspecEjeX.setEnabled(false);
						textFieldSensEspecEjeX.setEnabled(false);
						scoba.getLecturas().activarSensor(Sensor.ESPEC_X, false);
					}
					
					
				}
			});
			chckbxSensCupula.addActionListener(new ActionListener() 
			{
				public void actionPerformed(ActionEvent e) 			
				{
					if(chckbxSensCupula.isSelected())
					{
						textFieldADCSensCupula.setEnabled(true);
						textFieldSensCupula.setEnabled(true);
						scoba.getLecturas().activarSensor(Sensor.CUPULA, true); 
						// aca --> SOCBA -->LECTURAS --> HILOLECTURASENSOR--> sensoresactivos(hashmap)
					}
					else
					{
						textFieldADCSensCupula.setEnabled(false);
						textFieldSensCupula.setEnabled(false);

						scoba.getLecturas().activarSensor(Sensor.CUPULA, false);
					}
				
				}
			});
		chckbxSensPlataAdenAfu.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent e) 
			{			
				if(chckbxSensPlataAdenAfu.isSelected())
				{
					textFieldADCSensPlataADAF.setEnabled(true);
					textFieldSensPlataADAF.setEnabled(true);
					scoba.getLecturas().activarSensor(Sensor.PLATAF_AD_AF, true);
				}
				else
				{
					textFieldADCSensPlataADAF.setEnabled(false);
					textFieldSensPlataADAF.setEnabled(false);
					scoba.getLecturas().activarSensor(Sensor.PLATAF_AD_AF, false);
				}
				
			}
		});
		chckbxSensFinesDeCarrera.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent e) 
			{
				if(chckbxSensFinesDeCarrera.isSelected())
				{
					textFieldSensFinesDeCarrera.setEnabled(true);
					scoba.getLecturas().activarSensor(Sensor.FINES_CARRERA, true);
				}
				else
				{
					textFieldSensFinesDeCarrera.setEnabled(false);
					scoba.getLecturas().activarSensor(Sensor.FINES_CARRERA, false);
				}
											
				
			}
		});
		chckbxSensCheckPic.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent e) 
			{
				
				if(chckbxSensCheckPic.isSelected())
				{
					textFieldSensCheckPic.setEnabled(true);
					scoba.getLecturas().activarSensor(Sensor.FUNCIONAMIENTO, true);
				}
				else
				{
					textFieldSensCheckPic.setEnabled(false);
					scoba.getLecturas().activarSensor(Sensor.FUNCIONAMIENTO, false);
				}
					
				
				
				
			}
		});
		
		btnSensCargarValores = new JButton("Cargar Valores");
		btnSensCargarValores.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				getTextFieldFarc5v().setText( String.format("%.3f",scoba.getLecturas().getFac5vDelPic()));
				getTextFieldFacTempAlim1().setText(String.format("%.3f", scoba.getLecturas().getFacTempExtAlim()));
				getTextFieldFacTempAlim2().setText(String.format("%.3f", scoba.getLecturas().getFacTempEspejoAlim()));
				getTextFieldFacCorrTempExt().setText(String.format("%.3f",scoba.getLecturas().getTempExtFactorCorrec()));
				getTextFieldFacCorrTempEsp().setText(String.format("%.3f",scoba.getLecturas().getTempEspejoFactorCorrec()));
				getTextFieldFacPlaAR0().setText(String.format("%.3f",scoba.getLecturas().getFacPlatAR0()));
				getTextFieldFacPlaAR1().setText(String.format("%.3f",scoba.getLecturas().getFacPlatAR1()));
				getTextFieldFacPlaAD0().setText(String.format("%.3f",scoba.getLecturas().getFacPlatAD0()));
				getTextFieldFacPlaAD1().setText(String.format("%.3f",scoba.getLecturas().getFacPlatAD1()));
				getTextFieldFacPlaRad0().setText(String.format("%.3f",scoba.getLecturas().getFacPlatRad0()));
				getTextFieldFacPlaRad1().setText(String.format("%.3f",scoba.getLecturas().getFacPlatRad1()));
				getTextFieldFacCorrPlaAlt().setText(String.format("%.3f",scoba.getLecturas().getPlatafAltFactorCorrec()));
				getTextFieldFacCorrPlaRad().setText(String.format("%.3f",scoba.getLecturas().getPlatafRadioFactorCorrec()));
				getTextFieldFacCupGan().setText(String.format("%.3f",scoba.getLecturas().getFacCupGan()));
				getTextFieldFacCupOffset().setText(String.format("%.3f",scoba.getLecturas().getFacCupOffset()));
				getTextFieldFacCup0().setText(String.format("%.3f",scoba.getLecturas().getFacCup0()));
				getTextFieldFacCup1().setText(String.format("%.3f",scoba.getLecturas().getFacCup1()));
				getTextFieldFacCorrCup().setText(String.format("%.3f",scoba.getLecturas().getCupulaAzFactorCorrec()));
				getTextFieldFacEspGanX().setText(String.format("%.3f",scoba.getLecturas().getFacEspGanX()));
				getTextFieldFacEspGanY().setText(String.format("%.3f",scoba.getLecturas().getFacEspGanY()));
				getTextFieldFacEspGanFi().setText(String.format("%.3f",scoba.getLecturas().getFacEspGanFi()));
				getTextFieldFacEspOffsetX().setText(String.format("%.3f",scoba.getLecturas().getFacEspOffsetX()));
				getTextFieldFacEspOffsetY().setText(String.format("%.3f",scoba.getLecturas().getFacEspOffsetY()));
				getTextFieldFacEspOffsetFi().setText(String.format("%.3f",scoba.getLecturas().getFacEspOffsetFi()));
				getTextFieldFacCorrEspX().setText(String.format("%.3f",scoba.getLecturas().getEspXFactorCorrec()));
				getTextFieldFacCorrEspY().setText(String.format("%.3f",scoba.getLecturas().getEspYFactorCorrec()));
				getTextFieldFacCorrEspFi().setText(String.format("%.3f",scoba.getLecturas().getEspFiFactorCorrec()));
				getTextFieldSegCupGrad().setText(scoba.getLecturas().getFacSegCupGrad().toString());
				getTextFieldMinRampa().setText(String.format("%d",scoba.getTelescopio().getRampaValMinManopla()));
				getTextFieldMaxRampa().setText(String.format("%d",scoba.getTelescopio().getRampaValMaxManopla()));
				getTextFieldDelayRampa().setText(String.format("%d",scoba.getTelescopio().getRampaDelayManopla()));
				
				
			}
		});
		btnSensCargarValores.setBounds(214, 437, 123, 23);
		contentPane.add(btnSensCargarValores);
		
		btnSensCargarArchivo = new JButton("Cargar Archivo");
		btnSensCargarArchivo.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				
				
				
			}
		});
		btnSensCargarArchivo.setBounds(513, 437, 130, 23);
		contentPane.add(btnSensCargarArchivo);
		
		btnSensActualizarLecturas = new JButton("Actualizar Lecturas");
		btnSensActualizarLecturas.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				scoba.getLecturas().setFac5vDelPic(Double.parseDouble(getTextFieldFarc5v().getText()));
				scoba.getLecturas().setFacTempExtAlim( Double.parseDouble(getTextFieldFacTempAlim1().getText()));
				scoba.getLecturas().setFacTempEspejoAlim( Double.parseDouble(getTextFieldFacTempAlim2().getText()));
				scoba.getLecturas().setTempEspejoFactorCorrec(Double.parseDouble(getTextFieldFacCorrTempExt().getText()));
				scoba.getLecturas().setTempExtFactorCorrec(Double.parseDouble(getTextFieldFacCorrTempEsp().getText()));
				scoba.getLecturas().setFacPlatAR0(Double.parseDouble(getTextFieldFacPlaAR0().getText()));
				scoba.getLecturas().setFacPlatAR1(Double.parseDouble(getTextFieldFacPlaAR1().getText()));
				scoba.getLecturas().setFacPlatAD0(Double.parseDouble(getTextFieldFacPlaAD0().getText()));
				scoba.getLecturas().setFacPlatAD1(Double.parseDouble(getTextFieldFacPlaAD1().getText()));
				scoba.getLecturas().setFacPlatRad0(Double.parseDouble(getTextFieldFacPlaRad0().getText()));
				scoba.getLecturas().setFacPlatRad1(Double.parseDouble(getTextFieldFacPlaRad1().getText()));
				scoba.getLecturas().setPlatafAltFactorCorrec(Double.parseDouble(getTextFieldFacCorrPlaAlt().getText()));
				scoba.getLecturas().setPlatafRadioFactorCorrec(Double.parseDouble(getTextFieldFacCorrPlaRad().getText()));
				scoba.getLecturas().setFacCupGan(Double.parseDouble(getTextFieldFacCupGan().getText()));
				scoba.getLecturas().setFacCupOffset(Double.parseDouble(getTextFieldFacCupOffset().getText()));
				scoba.getLecturas().setFacCup0(Double.parseDouble(getTextFieldFacCup0().getText()));
				scoba.getLecturas().setFacCup1(Double.parseDouble(getTextFieldFacCup1().getText()));
				//VER ESTE VALOR DE CORRECCION DE LA CUPULA NO SE SI ESTA BIEN SACADO
				scoba.getLecturas().setCupulaAzFactorCorrec(Double.parseDouble(getTextFieldFacCorrCup().getText()));  
				
				scoba.getLecturas().setFacEspGanX(Double.parseDouble(getTextFieldFacEspGanX().getText()));
				scoba.getLecturas().setFacEspGanY(Double.parseDouble(getTextFieldFacEspGanY().getText()));
				scoba.getLecturas().setFacEspGanFi(Double.parseDouble(getTextFieldFacEspGanFi().getText()));
				scoba.getLecturas().setFacEspOffsetX(Double.parseDouble(getTextFieldFacEspOffsetX().getText()));
				scoba.getLecturas().setFacEspOffsetY(Double.parseDouble(getTextFieldFacEspOffsetY().getText()));
				scoba.getLecturas().setFacEspOffsetFi(Double.parseDouble(getTextFieldFacEspOffsetFi().getText()));
				scoba.getLecturas().setEspXFactorCorrec(Double.parseDouble(getTextFieldFacCorrEspX().getText()));
				scoba.getLecturas().setEspYFactorCorrec(Double.parseDouble(getTextFieldFacCorrEspY().getText()));
				scoba.getLecturas().setEspFiFactorCorrec(Double.parseDouble(getTextFieldFacCorrEspFi().getText()));
				scoba.getLecturas().setFacSegCupGrad(Integer.parseInt(getTextFieldSegCupGrad().getText()));
				scoba.getTelescopio().setRampaValMinManopla(Integer.parseInt(getTextFieldMinRampa().getText()));
				scoba.getTelescopio().setRampaValMaxManopla(Integer.parseInt(getTextFieldMaxRampa().getText()));
				scoba.getTelescopio().setRampaDelayManopla(Integer.parseInt(getTextFieldDelayRampa().getText()));
				
				
				
			}
		});
		btnSensActualizarLecturas.setBounds(362, 437, 123, 23);
		contentPane.add(btnSensActualizarLecturas);
		
		btnSensGuardarValores = new JButton("Guardar Valores");
		btnSensGuardarValores.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				scoba.guardarConfiguracion();
			}
		});
		btnSensGuardarValores.setBounds(670, 437, 123, 23);
		contentPane.add(btnSensGuardarValores);
		soloNumeros(textFieldFac5vPic);
		soloNumeros(textFieldFacTempAlim1);
		soloNumeros(textFieldFacTempAlim2);
		soloNumeros(textFieldFacPlaAR0);
		soloNumeros(textFieldFacPlaAR1);
		soloNumeros(textFieldFacPlaAD0);
		soloNumeros(textFieldFacPlaAD1);
		soloNumeros(textFieldFacPlaRad0);
		soloNumeros(textFieldFacEspGanY);
		soloNumeros(textFieldFacEspGanX);
		soloNumeros(textFieldFacCup1);
		soloNumeros(textFieldFacCup0);
		soloNumeros(textFieldFacCupOffset);
		soloNumeros(textFieldFacPlaRad1);
		soloNumeros(textFieldFacCupGan);
		soloNumeros(textFieldDelayRampa);
		soloNumeros(textFieldMaxRampa);
		soloNumeros(textFieldMinRampa);
		soloNumeros(textFieldFacEspOffsetX);
		soloNumeros(textFieldFacEspOffsetY);
		soloNumeros(textFieldFacEspOffsetFi);
		soloNumeros(textFieldFacEspGanFi);
		//soloNumeros(textFieldSegCupGrad);
		
		
		textFieldSegCupGrad = new JTextField();
		textFieldSegCupGrad.setBounds(457, 208, 60, 20);
		panelFactores.add(textFieldSegCupGrad);
		textFieldSegCupGrad.setColumns(10);
		
		JLabel lblFacsegcupgrad = new JLabel("facSegCupGrad");
		lblFacsegcupgrad.setHorizontalAlignment(SwingConstants.RIGHT);
		lblFacsegcupgrad.setVerticalAlignment(SwingConstants.TOP);
		lblFacsegcupgrad.setBounds(347, 211, 100, 14);
		panelFactores.add(lblFacsegcupgrad);
		
		JPanel panel = new JPanel();
		panel.setBounds(320, 294, 533, 132);
		contentPane.add(panel);
		panel.setBorder(new TitledBorder(null, "Factores de Correccion", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel.setLayout(null);
		
		JLabel lblFacCorrPlaAlt = new JLabel("facCorrPlaAlt");
		lblFacCorrPlaAlt.setBounds(179, 62, 89, 14);
		panel.add(lblFacCorrPlaAlt);
		lblFacCorrPlaAlt.setHorizontalAlignment(SwingConstants.RIGHT);
		
		textFieldFacCorrPlaAlt = new JTextField();
		textFieldFacCorrPlaAlt.setBounds(278, 59, 60, 20);
		panel.add(textFieldFacCorrPlaAlt);
		textFieldFacCorrPlaAlt.setColumns(10);
		soloNumeros(textFieldFacCorrPlaAlt);
		
		JLabel lblFacCorrPlaRad = new JLabel("facCorrPlaRad");
		lblFacCorrPlaRad.setBounds(179, 26, 89, 14);
		panel.add(lblFacCorrPlaRad);
		lblFacCorrPlaRad.setHorizontalAlignment(SwingConstants.RIGHT);
		
		textFieldFacCorrPlaRad = new JTextField();
		textFieldFacCorrPlaRad.setBounds(278, 23, 60, 20);
		panel.add(textFieldFacCorrPlaRad);
		textFieldFacCorrPlaRad.setColumns(10);
		soloNumeros(textFieldFacCorrPlaRad);
		
		JLabel lblFacTempExt = new JLabel("facCorrTempExt");
		lblFacTempExt.setBounds(10, 26, 89, 14);
		panel.add(lblFacTempExt);
		lblFacTempExt.setHorizontalAlignment(SwingConstants.RIGHT);
		
		textFieldFacCorrTempExt = new JTextField();
		textFieldFacCorrTempExt.setBounds(109, 23, 60, 20);
		panel.add(textFieldFacCorrTempExt);
		textFieldFacCorrTempExt.setColumns(10);
		soloNumeros(textFieldFacCorrTempExt);
		
		JLabel lblFacTempEsp = new JLabel("facCorrTempEsp");
		lblFacTempEsp.setBounds(10, 62, 89, 14);
		panel.add(lblFacTempEsp);
		lblFacTempEsp.setHorizontalAlignment(SwingConstants.RIGHT);
		
		textFieldFacCorrTempEsp = new JTextField();
		textFieldFacCorrTempEsp.setBounds(109, 59, 60, 20);
		panel.add(textFieldFacCorrTempEsp);
		textFieldFacCorrTempEsp.setColumns(10);
		soloNumeros(textFieldFacCorrTempEsp);
		
		JLabel lblFacCorrEspX = new JLabel("FacCorrEspX");
		lblFacCorrEspX.setBounds(348, 26, 89, 14);
		panel.add(lblFacCorrEspX);
		lblFacCorrEspX.setHorizontalAlignment(SwingConstants.RIGHT);
		
		JLabel lblFacCorrEspY = new JLabel("FacCorrEspY");
		lblFacCorrEspY.setBounds(348, 62, 89, 14);
		panel.add(lblFacCorrEspY);
		lblFacCorrEspY.setHorizontalAlignment(SwingConstants.RIGHT);
		
		JLabel lblFacCorrEspFi = new JLabel("FacCorrEspFi");
		lblFacCorrEspFi.setBounds(348, 96, 89, 14);
		panel.add(lblFacCorrEspFi);
		lblFacCorrEspFi.setHorizontalAlignment(SwingConstants.RIGHT);
		
		textFieldFacCorrEspX = new JTextField();
		textFieldFacCorrEspX.setBounds(447, 23, 60, 20);
		panel.add(textFieldFacCorrEspX);
		textFieldFacCorrEspX.setColumns(10);
		soloNumeros(textFieldFacCorrEspX);
		
		textFieldFacCorrEspY = new JTextField();
		textFieldFacCorrEspY.setBounds(447, 59, 60, 20);
		panel.add(textFieldFacCorrEspY);
		textFieldFacCorrEspY.setColumns(10);
		soloNumeros(textFieldFacCorrEspY);
		
		textFieldFacCorrEspFi = new JTextField();
		textFieldFacCorrEspFi.setBounds(447, 93, 60, 20);
		panel.add(textFieldFacCorrEspFi);
		textFieldFacCorrEspFi.setColumns(10);
		soloNumeros(textFieldFacCorrEspFi);
		
		JLabel lblFacCorrCup = new JLabel("facCorrCup");
		lblFacCorrCup.setBounds(179, 96, 89, 14);
		panel.add(lblFacCorrCup);
		lblFacCorrCup.setHorizontalAlignment(SwingConstants.RIGHT);
		
		textFieldFacCorrCup = new JTextField();
		textFieldFacCorrCup.setBounds(278, 93, 60, 20);
		panel.add(textFieldFacCorrCup);
		textFieldFacCorrCup.setColumns(10);
		soloNumeros(textFieldFacCorrCup);
		
		btnAyuda = new JButton("?");
		btnAyuda.setBackground(Color.BLUE);
		btnAyuda.setForeground(Color.BLUE);
		btnAyuda.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				
				
				try
				{
					if(!sensoresAyuda.isVisible())
						{						
						sensoresAyuda.setVisible(true);
						}
					else{
						sensoresAyuda.requestFocus();
						sensoresAyuda.setExtendedState(JFrame.NORMAL);
						}
				}
				catch(Exception e1)
				{
					sensoresAyuda = new SensoresAyuda();				
					sensoresAyuda.setVisible(true);
				}
				
				
			}
		});
		btnAyuda.setBounds(867, 25, 37, 23);
		contentPane.add(btnAyuda);
		
		
		
		
	
	
	
	}
	
	
	

/**
 * @param a
 * Metodo para validar textField
 */
public void soloNumeros(JTextField a){
		
		a.addKeyListener(new KeyAdapter(){
		
			public void keyTyped(KeyEvent e) {
				
				char c = e.getKeyChar();
				if(Character.isLetter(c)){
					
					getToolkit().beep();
					e.consume(); // que no te permita ingresar letras
				}
			}
		
			
		});
	}

	
	
	
	
	/* Getters*/
	public JTextField getTextFieldSensEspecEjeX()
	{
		return textFieldSensEspecEjeX;
	}
	public JTextField getTextFieldSensEspecEjeY() 
	{
		return textFieldSensEspecEjeY;
	}
	public JTextField getTextFieldSensEspecFi() 
	{
		return textFieldSensEspecFi;
	}
	public JTextField getTextFieldSensCupula() 
	{
		return this.textFieldSensCupula;
	}
	public JTextField getTextFieldSensTempExt() 
	{
		return textFieldSensTempExt;
	}
	public JTextField getTextFieldSensPlataADAF() 
	{
		return textFieldSensPlataADAF;
	}
	public JTextField getTextFieldSensCheckPic()
	{
		return textFieldSensCheckPic;
	}
	public JTextField getTextFieldSensFinesDeCarrera() 
	{
		return textFieldSensFinesDeCarrera;
	}
	public JTextField getTextFieldSensPlataArriAba()
	{
		return textFieldSensPlataArriAba;
	}
	public JTextField getTextFieldSensTempEsp()
	{
		return this.textFieldSensTempEsp;
	}
	public JCheckBox getChckbxSensEspecEjeX()
	{
		return chckbxSensEspecEjeX;
	}
	public JCheckBox getChckbxSensTempEsp() 
	{
		return chckbxSensTempEsp;
	}
	public JCheckBox getChckbxSensEspecEjeY() 
	{
		return chckbxSensEspecEjeY;
	}
	public JCheckBox getChckbxSensPlataAdenAfu()
	{
		return chckbxSensPlataAdenAfu;
	}
	public JCheckBox getChckbxSensCheckPic()
	{
		return chckbxSensCheckPic;
	}
	public JCheckBox getChckbxSensEspecFi()
	{
		return chckbxSensEspecFi;
	}
	public JCheckBox getChckbxSensCupula()
	{
		return chckbxSensCupula;
	}
	public JCheckBox getChckbxSensPlataARAB() 
	{
		return chckbxSensPlataARAB;
	}
	public JCheckBox getChckbxSensFinesDeCarrera() 
	{
		return chckbxSensFinesDeCarrera;
	}
	public JCheckBox getChckbxSensTempExt()
	{
		return chckbxSensTempExt;
	}

	public JTextField getTextFieldADCSensCupula() {
		return textFieldADCSensCupula;
	}

	public JTextField getTextFieldADCSensEspecEjeX() {
		return textFieldADCSensEspecEjeX;
	}

	public JTextField getTextFieldADCSensEspecEjeY() {
		return textFieldADCSensEspecEjeY;
	}

	public JTextField getTextFieldADCSensEspecFi() {
		return textFieldADCSensEspecFi;
	}

	public JTextField getTextFieldADCSensTempExt() {
		return textFieldADCSensTempExt;
	}

	public JTextField getTextFieldADCSensTempEsp() {
		return textFieldADCSensTempEsp;
	}

	public JTextField getTextFieldADCSensPlataArriAba() {
		return textFieldADCSensPlataArriAba;
	}

	public JTextField getTextFieldADCSensPlataADAF() {
		return textFieldADCSensPlataADAF;
	}

	public JTextField getTextFieldFarc5v() {
		return textFieldFac5vPic;
	}

	public JTextField getTextFieldFacTempAlim1() {
		return textFieldFacTempAlim1;
	}

	public JTextField getTextFieldFacTempAlim2() {
		return textFieldFacTempAlim2;
	}

	public JTextField getTextFieldFacCorrTempExt() {
		return textFieldFacCorrTempExt;
	}

	public JTextField getTextFieldFacCorrTempEsp() {
		return textFieldFacCorrTempEsp;
	}

	public JTextField getTextFieldFacPlaAR0() {
		return textFieldFacPlaAR0;
	}

	public JTextField getTextFieldFacPlaAR1() {
		return textFieldFacPlaAR1;
	}

	public JTextField getTextFieldFacPlaAD0() {
		return textFieldFacPlaAD0;
	}

	public JTextField getTextFieldFacPlaAD1() {
		return textFieldFacPlaAD1;
	}

	public JTextField getTextFieldFacPlaRad0() {
		return textFieldFacPlaRad0;
	}

	public JTextField getTextFieldFacEspGanY() {
		return textFieldFacEspGanY;
	}

	public JTextField getTextFieldFacEspGanX() {
		return textFieldFacEspGanX;
	}

	public JTextField getTextFieldFacCorrCup() {
		return textFieldFacCorrCup;
	}

	public JTextField getTextFieldFacCup1() {
		return textFieldFacCup1;
	}

	public JTextField getTextFieldFacCup0() {
		return textFieldFacCup0;
	}

	public JTextField getTextFieldFacCupOffset() {
		return textFieldFacCupOffset;
	}

	public JTextField getTextFieldFacPlaRad1() {
		return textFieldFacPlaRad1;
	}

	public JTextField getTextFieldFacCorrPlaAlt() {
		return textFieldFacCorrPlaAlt;
	}

	public JTextField getTextFieldFacCorrPlaRad() {
		return textFieldFacCorrPlaRad;
	}

	public JTextField getTextFieldFacCupGan() {
		return textFieldFacCupGan;
	}

	public JTextField getTextFieldDelayRampa() {
		return textFieldDelayRampa;
	}

	public JTextField getTextFieldMaxRampa() {
		return textFieldMaxRampa;
	}

	public JTextField getTextFieldMinRampa() {
		return textFieldMinRampa;
	}

	public JTextField getTextFieldFacEspOffsetX() {
		return textFieldFacEspOffsetX;
	}

	public JTextField getTextFieldFacEspOffsetY() {
		return textFieldFacEspOffsetY;
	}

	public JTextField getTextFieldFacEspOffsetFi() {
		return textFieldFacEspOffsetFi;
	}

	public JTextField getTextFieldFacCorrEspX() {
		return textFieldFacCorrEspX;
	}

	public JTextField getTextFieldFacCorrEspY() {
		return textFieldFacCorrEspY;
	}

	public JTextField getTextFieldFacCorrEspFi() {
		return textFieldFacCorrEspFi;
	}

	public JTextField getTextFieldFacEspGanFi() {
		return textFieldFacEspGanFi;
	}
	
	
	
	public JTextField getTextFieldSegCupGrad() {
		return textFieldSegCupGrad;
	}

	public void setTextFieldSegCupGrad(JTextField textFieldSegCupGrad) {
		this.textFieldSegCupGrad = textFieldSegCupGrad;
	}

	public JButton getBtnSensCargarArchivo() {
		return btnSensCargarArchivo;
	}
	public JButton getBtnSensGuardarVarlos() {
		return btnSensGuardarValores;
	}
	public JButton getBtnSensCargarValores() {
		return btnSensCargarValores;
	}
	public JButton getBtnSensActualizarLecturas() {
		return btnSensActualizarLecturas;
	}

	public boolean isFlagMostrar() {
		return flagMostrar;
	}

	public void setFlagMostrar(boolean flagMostrar) {
		this.flagMostrar = flagMostrar;
	}

	public static Scoba getScoba() {
		return scoba;
	}
	
	public void actualizarCheckBoxes()
	{
		this.getChckbxSensCupula().setSelected(this.scoba.getLecturas().isSensorActivo(Sensor.CUPULA));
		textFieldADCSensCupula.setEnabled(this.scoba.getLecturas().isSensorActivo(Sensor.CUPULA));
		textFieldSensCupula.setEnabled(this.scoba.getLecturas().isSensorActivo(Sensor.CUPULA));
		this.getChckbxSensPlataAdenAfu().setSelected(this.scoba.getLecturas().isSensorActivo(Sensor.PLATAF_AD_AF));
		textFieldADCSensPlataADAF.setEnabled(this.scoba.getLecturas().isSensorActivo(Sensor.PLATAF_AD_AF));
		textFieldSensPlataADAF.setEnabled(this.scoba.getLecturas().isSensorActivo(Sensor.PLATAF_AD_AF));
		this.getChckbxSensPlataARAB().setSelected(this.scoba.getLecturas().isSensorActivo(Sensor.PLATAF_AR_AB));
		
	}
}

class HiloActualizacionSensoresGUI extends Thread
{
	private Scoba scoba;
	private Integer delay = 100;
	
	public HiloActualizacionSensoresGUI(Scoba sco)
	{
		this.scoba = sco;
	}
	
	public void run()
	{
		while(this.scoba.getSensoresGUI().isFlagMostrar())
		{
			/* Actualizar pantalla Sensores */
		    if(this.scoba.getLecturas().isSensorActivo(Sensor.CUPULA))
		    {
		    	this.scoba.getSensoresGUI().getTextFieldADCSensCupula().setText(this.scoba.getLecturas().getSensores().get(Sensor.CUPULA).toString());
		    	this.scoba.getSensoresGUI().getTextFieldSensCupula().setText(String.format("%d", this.scoba.getLecturas().getCupulaAzimut( this.scoba.getLecturas().getSensores().get(Sensor.CUPULA))));
		    }
		    if(this.scoba.getLecturas().isSensorActivo(Sensor.ESPEC_X))
		    {
		    	this.scoba.getSensoresGUI().getTextFieldADCSensEspecEjeX().setText(this.scoba.getLecturas().getSensores().get(Sensor.ESPEC_X).toString());
		    	this.scoba.getSensoresGUI().getTextFieldSensEspecEjeX().setText(String.format("%.2f",this.scoba.getLecturas().getEspX( this.scoba.getLecturas().getSensores().get(Sensor.ESPEC_X))));
		    }
		    if(this.scoba.getLecturas().isSensorActivo(Sensor.ESPEC_Y))
		    {
		    	this.scoba.getSensoresGUI().getTextFieldADCSensEspecEjeY().setText(this.scoba.getLecturas().getSensores().get(Sensor.ESPEC_Y).toString());
		    	this.scoba.getSensoresGUI().getTextFieldSensEspecEjeY().setText(String.format("%.2f", this.scoba.getLecturas().getEspY(this.scoba.getLecturas().getSensores().get(Sensor.ESPEC_Y))));
		    }
		    if(this.scoba.getLecturas().isSensorActivo(Sensor.ESPEC_RED))
		    {
		    	this.scoba.getSensoresGUI().getTextFieldADCSensEspecFi().setText(this.scoba.getLecturas().getSensores().get(Sensor.ESPEC_RED).toString());
		    	this.scoba.getSensoresGUI().getTextFieldSensEspecFi().setText(String.format("%.2f",this.scoba.getLecturas().getEspFi(this.scoba.getLecturas().getSensores().get(Sensor.ESPEC_RED))));
		    }
		    if(this.scoba.getLecturas().isSensorActivo(Sensor.TEMP_EXTERIOR))
		    {
		    	this.scoba.getSensoresGUI().getTextFieldADCSensTempExt().setText( this.scoba.getLecturas().getSensores().get(Sensor.TEMP_EXTERIOR).toString());
		    	this.scoba.getSensoresGUI().getTextFieldSensTempExt().setText(String.format("%.2f", this.scoba.getLecturas().getTempExtGrados(this.scoba.getLecturas().getSensores().get(Sensor.TEMP_EXTERIOR))));
		    }
		    if(this.scoba.getLecturas().isSensorActivo(Sensor.TEMP_ESPEJO))
		    {
		    	this.scoba.getSensoresGUI().getTextFieldADCSensTempEsp().setText(this.scoba.getLecturas().getSensores().get(Sensor.TEMP_ESPEJO).toString());
		    	this.scoba.getSensoresGUI().getTextFieldSensTempEsp().setText(String.format("%.2f", this.scoba.getLecturas().getTempEspejoGrados(this.scoba.getLecturas().getSensores().get(Sensor.TEMP_ESPEJO))));

		    }
		    if(this.scoba.getLecturas().isSensorActivo(Sensor.PLATAF_AR_AB))
		    {
		    	this.scoba.getSensoresGUI().getTextFieldADCSensPlataArriAba().setText(this.scoba.getLecturas().getSensores().get(Sensor.PLATAF_AR_AB).toString());

		    }
		    if(this.scoba.getLecturas().isSensorActivo(Sensor.PLATAF_AD_AF))
		    {
		    	Integer lec = this.scoba.getLecturas().getSensores().get(Sensor.PLATAF_AD_AF);
		    	this.scoba.getSensoresGUI().getTextFieldADCSensPlataADAF().setText(lec.toString());
		    	this.scoba.getSensoresGUI().getTextFieldSensPlataADAF().setText(String.format("%.2f", this.scoba.getLecturas().getPlataformaRadio(lec)));
		    }
		    if(this.scoba.getLecturas().isSensorActivo(Sensor.PLATAF_AR_AB) && this.scoba.getLecturas().isSensorActivo(Sensor.PLATAF_AD_AF))
		    {
		    	this.scoba.getSensoresGUI().getTextFieldSensPlataArriAba().setText(String.format("%.2f", this.scoba.getLecturas().getPlataformaAltura(
		    			this.scoba.getLecturas().getSensores().get(Sensor.PLATAF_AR_AB), this.scoba.getLecturas().getSensores().get(Sensor.PLATAF_AD_AF))));
		    }
		    		    
		    if(this.scoba.getLecturas().isSensorActivo(Sensor.FUNCIONAMIENTO))
		    {
		    	this.scoba.getSensoresGUI().getTextFieldSensCheckPic().setText(this.scoba.getLecturas().getSensores().get(Sensor.FUNCIONAMIENTO).toString());
		    }
		    
		    if(this.scoba.getLecturas().isSensorActivo(Sensor.FINES_CARRERA))
		    {
		    	this.scoba.getSensoresGUI().getTextFieldSensFinesDeCarrera().setText(this.scoba.getLecturas().getSensores().get(Sensor.FINES_CARRERA).toString());
			}
		    
		   // if(this.scoba.getLecturas().getHiloLecturaPalpador().isSensorPalpadorActivo())
		   // {
		   // 	this.scoba.getLblPalpador().setToolTipText(String.format("%.2f", this.scoba.getEspejoSecundario().getPosicion()));
		   // }
		    
		    
			try
			{
				Thread.sleep(delay);
			} catch (InterruptedException e)
			{
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
		
		
	}
}
		
